package com.tools.mytools.encrypt;

import java.text.SimpleDateFormat;
import java.util.Locale;

public class TimeUtil {
	public static String formateTime(long time) {
		return new SimpleDateFormat("yyyy/MM/dd hh:mm:ss", Locale.getDefault())
				.format(time);
	}

	public static String formatTimeInterval(long millis) {
		long seconds = millis / 1000;
		long minutes = seconds / 60;
		long hours = minutes / 60;
		long days = hours / 24;
		seconds = seconds % 60;
		minutes = minutes % 60;
		hours = hours % 24;
		String output = "";
		if (days > 0) {
			output += days + "day(s) ";
		}

		if (hours > 0) {
			output += hours + "hour(s) ";
		}

		if (minutes > 0) {
			output += minutes + "minute(s) ";
		}

		if (seconds > 0) {
			output += seconds + "second(s) ";
		}

		return output;
	}
}
